home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / INTR.ASM < prev    next >
Assembly Source File  |  1989-04-09  |  2KB  |  79 lines

  1. Comment *
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │ Title   : intr                                 │
  4. │ Purpose : Allow a interrupt call similar to the Turbo Pascal intr call.    │
  5. │                                         │
  6. │ Notes   : You must define a structure:                     │
  7. │        struct treg { unsigned int ax,bx,cx,dx,si,di,ds,es,flags;};      │
  8. │                                         │
  9. │        It is important to define the registers in exactly this order or │
  10. │        you will get unpredictable results !!!!                 │
  11. │                                         │
  12. │Usage      : intr(0x10,®ister);                         │
  13. │                                         │
  14. │ Hints    : you may also find the following macro useful:             │
  15. │         #define msdos(_wreg) intr(0x21,_wreg)                 │
  16. │                                         │
  17. │    Written by Jack Zucker - 75766,1336    301-794-5950  on 2-10-86      │
  18. └────────────────────────────────────────────────────────────────────────────┘
  19.  *
  20.     assume cs:_text
  21. _text    segment public byte 'code'
  22.     public _intr
  23.  
  24. _intr    proc near
  25.  
  26.     push bp
  27.     mov bp,sp
  28.     push si
  29.     push di
  30.     push es
  31.     push ds
  32.     mov bx,[bp+6]        ; get address of register record
  33.     mov ax,[bx+0]        ; reg.ax
  34.     mov cx,[bx+4]        ; reg.cx
  35.     mov dx,[bx+6]        ; reg.dx
  36.     mov si,[bx+8]        ; reg.si
  37.     mov di,[bx+10]        ; reg.di
  38.     mov es,[bx+14]        ; reg.es
  39.     push [bx+2]        ; save reg.bx
  40.     push bx         ; save real bx value
  41.     mov bl,[bp+4]        ; get interrupt number in bl
  42.     mov byte ptr cs:intlabel+1,bl ; put int into code segment
  43.     pop bx            ; restore actual bx value
  44.     push [bx+12]        ; push reg.ds on stack
  45.     pop ds            ; get value into ds
  46.     pop bx            ; set real bx from reg.bx
  47.     push bp         ; Save Base Pointer
  48. intlabel    label near
  49.     int 0FFh
  50.     pop bp
  51.     mov cs:saveds,ds    ; save the interrupt version of ds in word stor
  52.     pop ds            ; get original ds back
  53.     pushf            ; save flags
  54.     push bx         ; save bx locally
  55.     mov bx,[bp+6]        ; get address of register record
  56.     mov [bx+0],ax        ; set reg.ax
  57.     mov [bx+4],cx        ; set reg.cx
  58.     mov [bx+6],dx        ; set reg.dx
  59.     mov [bx+8],si        ; set reg.si
  60.     mov [bx+10],di        ; set reg.di
  61.     push ax         ; save ax locally
  62.     mov ax,cs:saveds
  63.     mov [bx+12],ax        ; set reg.ds from saved variable
  64.     pop ax            ; restore ax
  65.     mov [bx+14],es        ; set reg.es
  66.     pop [bx+2]        ; set reg.bx
  67.     pop [bx+16]        ; set reg.flags
  68.     pop es
  69.     pop di
  70.     pop si
  71.     mov sp,bp
  72.     pop  bp
  73.     cld
  74.     ret
  75. _intr    endp
  76. saveds    dw    0
  77. _text    ends
  78. end
  79.